#coding:utf-8

from flask import Flask
from flask import abort
from flask.ext.script import Manager

app = Flask(__name__)

# app.config.from_pyfile('config.ini')
manager = Manager(app)

@app.route("/")
def index():
    return "index"

@app.before_first_request
def before_first_request():
    print("before_first_request")

@app.before_request
def before_request():
    print("before_request")
    a = 1/0
    abort(500)
    print(11111111111111111111)

@app.after_request
def after_request(response):
    print("after_request")
    response.headers['Content-Type'] = "application/json"
    return response

@app.teardown_request
def teardown_request(e):
    print("teardown_request")

@app.errorhandler(500)
def internal_server_error(e):
    return "Not Found"

@app.errorhandler(ZeroDivisionError)
def zeor_division_error(e):
    return "NO 0"


if __name__ == '__main__':
    manager.run()
    # app.run()